import 'package:flutter/material.dart';
import '../utils/util.dart';

class MyRouterConfig {
  static Route<dynamic>? generateRoute(RouteSettings settings) {
    for (GetPage page in RouterPages.getPages) {
      if (settings.name == page.name) {
        final Function pageContentBuilder = page.page;
        if (settings.arguments != null) {
          final Route route = MaterialPageRoute(
              builder: (context) =>
                  pageContentBuilder(context, arguments: settings.arguments),
              settings: RouteSettings(name: page.name));

          return route;
        } else {
          final Route route = MaterialPageRoute(
              builder: (context) => pageContentBuilder(context),
              settings: RouteSettings(name: page.name));
          return route;
        }
      }
    }
    return null;
  }
}
